﻿@{
    ViewData["Title"] = "阅卷申请";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section head{
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/animate.min.css" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet" />
    <link href="/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .panel-actions .btn-sm {
            float: right;
            margin-top: -6px;
            margin-left: 5px;
        }

        .panel-body {
            height: 445px;
            padding: 0px;
            overflow-x: hidden;
            overflow-y: auto;
        }

            .panel-body div {
                padding: 5px 10px;
            }

                .panel-body div.sel {
                    background-color: #dff0d8;
                    color: #3c763d;
                    font-weight: bold;
                }

        .checkbox, .radio {
            margin-top: 0px;
            margin-bottom: 0px;
        }

        .input-group {
            margin-bottom: 10px;
            width: 100%;
        }

        .input-group-addon {
            width: 100px;
        }
    </style>
}
<form id="form1" runat="server">
    <div id="dContent">
        <table id="tab" style="width: 100%;">
            <colgroup>
                <col style="width: 400px;" />
                <col style="width: auto;" />
            </colgroup>
            <tr>
                <td style="vertical-align: top;">
                    <div class="panel panel-default" style="margin-bottom: 0px;">
                        <div class="panel-heading">
                            <div class="panel-actions">
                                <span id="sCount" style="float: right;">共 0 条</span>
                                <i class="fa fa-folder-open"></i>&nbsp;档案
                            </div>
                        </div>
                        <div class="panel-body" id="dFiles" style="height: 342px;">
                        </div>
                    </div>
                </td>
                <td style="vertical-align: top; padding-left: 10px;">
                    <div class="input-group">
                        <span class="input-group-addon">申请人</span>
                        <asp:TextBox ID="txtUserName" runat="server" CssClass="form-control" ReadOnly="true"></asp:TextBox>
                    </div>
                    <div class="input-group">
                        <span class="input-group-addon">天数</span>
                        <asp:TextBox ID="txtApplyDays" runat="server" CssClass="form-control" TextMode="Number" MaxLength="2" dataType="null,zzs,int,int30" Msg="天数为空或者天数不得超过30天!"></asp:TextBox>
                    </div>
                    <div class="input-group" style="margin-bottom: 0px;">
                        <span class="input-group-addon">理由</span>
                        <asp:TextBox ID="txtApplyReason" runat="server" CssClass="form-control" TextMode="MultiLine" Height="300"></asp:TextBox>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <div class="zui-footer">
        <button id="btnSave" class="btn btn-primary btn-sm" type="button" onclick="SaveApply()">申请</button>
        <button id="btnClose" class="btn btn-default btn-sm" type="button" onclick="closePage()">关闭</button>
    </div>
</form>
    @section scripts{
        <script src="/js/jquery.min.js?v=2.1.4"></script>
        <script src="/js/bootstrap.min.js?v=3.3.6"></script>
        <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
        <script src="/js/plugins/dataTables/jquery.dataTables.js"></script>
        <script src="/js/plugins/dataTables/dataTables.bootstrap.js"></script>

        <script src="/js/My97DatePicker/WdatePicker.js"></script>
        <script src="/js/plugins/layer/layer.min.js"></script>
        <script src="/js/store.js"></script>
        <script src="/js/plugins/iCheck/icheck.min.js"></script>
        <script src="/js/verification.js"></script>
        <script src="/js/zuiCode.js"></script>
        <script type="text/javascript">
            $(function () {
                var _FIDS = store.get("FilesApply_FIDS");
                var len = _FIDS.split(',').length;
                $("#sCount").html("共 " + len + " 条");
                GetFiles();
            })

            //获取档案
            function GetFiles() {
                var _FIDS = store.get("FilesApply_FIDS");
                $.ajax({
                    type: "post",
                    url: "/ashx/FilesAuthority.ashx",
                    dataType: "json",
                    async: false,
                    data: { type: "GetFiles", FIDS: _FIDS },
                    success: function (msg) {
                        if (msg.result == 1) {
                            $("#dFiles").html(msg.htmlStr);
                        }
                    }
                });
            }

            //移除档案
            function RemoveFileNo(_id) {
                var obj = document.getElementById(_id);
                obj.remove();
                var len = document.getElementById("dFiles").getElementsByTagName("a").length;
                $("#sCount").html("共 " + len + " 条");
            }

            //提交申请
            function SaveApply() {
                if (verfic('tip', '#dContent') == false) {
                    return false;
                }
                DataLoading();
                var _FIDS = "";
                //获取授权的档案
                var len = document.getElementById("dFiles").getElementsByTagName("a").length;
                for (var i = 0; i < len; i++) {
                    var _id = document.getElementById("dFiles").getElementsByTagName("a")[i].id;
                    if (i == 0) {
                        _FIDS = _id;
                    }
                    else {
                        _FIDS += "," + _id;
                    }
                }

                var _ApplyDays = $.trim($("#txtApplyDays").val());//天数
                var _ApplyReason = $.trim($("#txtApplyReason").val());//理由
                if (_ApplyDays > 0 && _ApplyDays <= 30) {
                    $.ajax({
                        type: "post",
                        url: "/ashx/FilesApply.ashx",
                        dataType: "json",
                        async: true,
                        data: { type: "SaveApply", FIDS: _FIDS, ApplyDays: _ApplyDays, ApplyReason: _ApplyReason },
                        success: function (msg) {
                            if (msg.result == 1) {
                                $("#htmlTip").remove();
                                SetToastOn();
                                showTip("申请已提交，请耐心等待管理员审批！", 1, 2);
                            }
                        }
                    });
                }
                else {
                    showTip("申请天数必须大于零小于30天！", 2, 1);
                }
            }
        </script>
    }
